package com.erp.common.config;

import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringBootConfiguration;
import org.springframework.web.servlet.config.annotation.CorsRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@SpringBootConfiguration
@MapperScan("com.erp.main.mapper")
public class MyMebMvcConfig implements WebMvcConfigurer {

    /**
     * 处理跨域
     * @param registry
     */
    @Override
    public void addCorsMappings(CorsRegistry registry) {
        registry.addMapping("/**")
                .allowedOrigins("*")
                .allowCredentials(false)  //是否允许客户端携带cookie 如果为true 则allowedOrigins它的值不允许为*
                .allowedMethods("*")
                .allowedHeaders("*")
                .maxAge(3600);
    }
}
